home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / eplain / merge < prev    next >
Text File  |  1994-05-01  |  3KB  |  79 lines

  1. #!/bin/sh
  2. # Merge the constituent files with xeplain.tex to produce eplain.tex.
  3.  
  4. # Usually we are called from the Makefile, and the `version' variable is set.
  5. if test -z "$version"; then
  6.   echo "No version number, using xx!"
  7.   version=xx
  8. fi
  9.  
  10. btxtmp=/tmp/mergebtx$$
  11. common1tmp=/tmp/mergec1$$
  12. common2tmp=/tmp/mergec2$$
  13. common3tmp=/tmp/mergec3$$
  14. eplaintmp=/tmp/mergepl$$
  15. arrow1tmp=/tmp/mergea1$$
  16. arrow2tmp=/tmp/mergea2$$
  17. finaltmp=/tmp/mergefn$$
  18. pathtmp=/tmp/mergepa$$
  19.  
  20. rm -f eplain.tex
  21.  
  22. # Use this regexp to strip comments with egrep.
  23. commentre='^ *%([^%]|$)'
  24.  
  25. # Extract the relevant parts of btxmac.tex (without comments).
  26. egrep -v "$commentre" btxmac.tex                    \
  27.   | sed -n                                \
  28.         -e "1,/^%% \[\[\[start .*\]\]\]/w $common1tmp"            \
  29.         -e "/^%% \[\[\[start .*\]\]\]/,/^%% \[\[\[end .*\]\]\]/w $btxtmp" \
  30.         -e "/^%% \[\[\[end .*\]\]\]/,\$w $common2tmp"
  31.  
  32. # Get texnames.sty and path.sty.  Remove the announcement, as well as
  33. # the comments.
  34. egrep -v "$commentre|immediate" texnames.sty > $common3tmp
  35. egrep -v "$commentre|immediate" path.sty > $pathtmp
  36.  
  37. # Get arrow.tex.
  38. egrep -v "$commentre" arrow.tex \
  39.   | sed -n                            \
  40.         -e '1,/catcode.*\&.*4/w '"$arrow1tmp"            \
  41.         -e '/catcode.*\&.*4/,$w '"$arrow2tmp"
  42.  
  43. # Merge the above into xeplain, calling the result eplain.  Also change the
  44. # `filename' in the comment.
  45. egrep -v "$commentre" xeplain.tex                    \
  46.   | sed -e s/xeplain/eplain/                        \
  47.         -e "/^%% \[\[\[here is the first.*\]\]\]/r $common1tmp"        \
  48.         -e "/^  %% \[\[\[here are the BibTeX.*\]\]\]/r $btxtmp"        \
  49.         -e "/^%% \[\[\[here is the second.*\]\]\]/r $common2tmp"    \
  50.         -e "/^%% \[\[\[include texnames.*\]\]\]/r $common3tmp"        \
  51.         -e "/^%% \[\[\[include path.*\]\]\]/r $pathtmp"            \
  52.         -e "/^  %% \[\[\[include arrow1\]\]\]/r $arrow1tmp"        \
  53.         -e "/^  %% \[\[\[include arrow2\]\]\]/r $arrow2tmp"        \
  54.     > $eplaintmp
  55.  
  56. # Remove our [[[...]]] markers and \endinput's.
  57. egrep -v '\[\[\[|^ *$|\\endinput' $eplaintmp > eplain.tex
  58.  
  59. # Fix header fields.
  60. add-date eplain.tex
  61. add-version $version eplain.tex
  62. fix-checksum eplain.tex
  63.  
  64. # Old checksum computation:
  65. #checksum=`wc < $eplaintmp | sed -n "s/^ *//"`
  66. # Replace the checksum in the old file.  We really should loop here,
  67. # since one iteration may not be enough.  Only replace the first
  68. # checksum, since the second is for btxmac.
  69. #sed -e "1,50s/checksum = .*,/checksum = \"$checksum\",/" $eplaintmp \
  70. #  > eplain.tex
  71.  
  72. chmod a-w eplain.tex
  73. #ls -lt btxmac.tex path.sty texnames.sty xeplain.tex eplain.tex arrow.tex
  74. #wc eplain.tex
  75. #grep 'checksum.*=' eplain.tex
  76.  
  77. rm -f $btxtmp $eplaintmp $common1tmp $common2tmp $common3tmp $finaltmp
  78. rm -f $arrow1tmp $arrow2tmp $pathtmp
  79.